package com.github.zzay.news.feign.fallback;

import com.github.zzay.common.core.model.ResponseBean;
import com.github.zzay.news.dto.NewsDto;
import com.github.zzay.news.feign.NewsServiceClient;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

/**
 * @author zzay
 * @className UserServiceClientFallbackImpl
 * @description User Service Client Fallback Factory Implementation
 * @create 2022/06/06 15:11
 */
@Slf4j
@Data
@Component
public class NewsServiceClientFallbackImpl implements NewsServiceClient {

    /**
     * Throwable
     */
    private Throwable throwable;

    /**
     * 根据新闻 id 获取新闻
     *
     * @param ids ids
     * @return 包含用户详细信息列表的响应 Bean
     */
    @Override
    public ResponseBean getNewsById(Long[] ids) {
        log.error("OpenFeign getNewsById failed: {}, {}", ids, throwable);
        return null;
    }

    /**
     * 查询新闻数量
     *
     * @param newsDto newsDto
     * @return 包含新闻数量的响应 Bean
     */
    @Override
    public ResponseBean getNewsCount(NewsDto newsDto) {
        log.error("OpenFeign getNewsCount failed: {}, {}", newsDto, throwable);
        return new ResponseBean(HttpStatus.BAD_REQUEST.value(), "failed", 0);
    }

    /**
     * 添加新闻
     *
     * @param newsDto newsDto
     * @return 包含请求处理结果的响应 Bean
     */
    @Override
    public ResponseBean createNews(NewsDto newsDto) {
        log.error("OpenFeign createNews failed: {}, {}", newsDto, throwable);
        return null;
    }

    /**
     * 删除新闻
     *
     * @param newsDto newsDto
     * @return 包含请求处理结果的响应 Bean
     */
    @Override
    public ResponseBean deleteNews(NewsDto newsDto) {
        log.error("OpenFeign deleteNews failed: {}, {}", newsDto, throwable);
        return null;
    }

    /**
     * 编辑新闻
     *
     * @param newsDto newsDto
     * @return 包含请求处理结果的响应 Bean
     */
    @Override
    public ResponseBean editNews(NewsDto newsDto) {
        log.error("OpenFeign editNews failed: {}, {}", newsDto, throwable);
        return null;
    }

    /**
     * 审核新闻
     *
     * @param newsDto newsDto
     * @return 包含请求处理结果的响应 Bean
     */
    @Override
    public ResponseBean auditNews(NewsDto newsDto) {
        log.error("OpenFeign auditNews failed: {}, {}", newsDto, throwable);
        return null;
    }

}
